package com.zerotwo.exam.center.mapper;

import com.zerotwo.exam.center.enums.QuestionTypeEnum;
import com.zerotwo.exam.center.model.Question;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zerotwo.exam.center.model.QuestionItem;
import com.zerotwo.exam.center.model.Questions;
import com.zerotwo.exam.center.vo.QuestionInfoVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * @author 02
 * @version 1.0
 * @Date 2024/7/5
 * @Description 题目信息 Mapper 接口
 */
@Mapper
public interface QuestionMapper extends BaseMapper<Question> {
    QuestionInfoVo questionInfo(Integer id);
    List<QuestionInfoVo> examQuestionInfo(Integer examId);
    List<Question> examQuestion(Integer examId);
    //导出题目
    @Select("SELECT q.*,qi.content AS contents, qi.answer AS answer,qi.question_id AS question_id  FROM eq_question q INNER JOIN eq_question_item qi ON (q.id = qi.question_id)")
    List<Question> exportExcel();
    //导入题目信息
    @Insert("INSERT INTO eq_question (id, content, type, difficulty, score, tag_id, teacher_id, is_public, course_id, created_at, updated_at) VALUES (#{id}, #{content}, #{type}, #{difficulty}, #{score}, #{tagId}, #{teacherId}, #{isPublic},#{courseId}, #{createdAt}, #{updatedAt})")
    Integer importExcel(Question question);
    @Insert("INSERT INTO eq_question_item (id, content, question_id, answer) VALUES (#{id}, #{content},#{questionId}, #{answer})")
    Integer importExcels(QuestionItem questionItem);
}
